package com.allwees.bs.core.model.ops.constant;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * 广告位置
 * @Author Daniel
 * @Version 1.0.0
 * @Description
 * @CreateTime 2020/10/16 11:10
 */
@Getter
public enum AdPositionEnum {
    HOME_BANNER(1,"首页Banner"),
    HOME_POPUPS(2,"APP启动页"),
    CATETORY_BANNER(3,"类目Banner"),
    PRODUCT_LIST(4,"商品列表页"),
    PRODUCT_DETAIL(5,"商品详情页"),
    PAY_SUCCESS(6,"支付成功页"),
    ;

    @EnumValue
    private int code;

    private String name;

    AdPositionEnum(int code, String name){
        this.code = code;
        this.name = name;
    }

    @JsonValue
    public int getCode() {
        return this.code;
    }

    @JsonCreator
    public static AdPositionEnum getByCode(int code) {
        for (AdPositionEnum position : AdPositionEnum.values()) {
            if (code == position.code) {
                return position;
            }
        }
        return null;
    }
}
